Page({

  /**
   * 页面的初始数据
   */
  data: {
    showHide: true,
    stylesse:true,
    timer: 1,
    allsec: 2,
    shopId: 1,
    dates: {},
    list:[],
    styles:false,
  },

  fxView: function() {
    this.setData({
      showHide: false
    })
  },

  xhsj: function() {
    this.setData({
      showHide: true
    })
  },

  syView: function() {
    wx.switchTab({
      url: '../index/index',
    })
  },

  gwcView: function() {
    wx.switchTab({
      url: '../shopping/shopping',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    var dates = JSON.parse(options.data)
    that.setData({
      dates: dates
    })
    that.data.allsecs = this.data.dates.hours * 1 * 3600 + this.data.dates.minutes * 1 * 60 + this.data.dates.seconds * 1;
    that.data.timer = setInterval(function() {
      that.setData({
        dates: {
          hours: addZero(Math.floor(that.data.allsecs / 3600)),
          minutes: addZero(Math.floor((that.data.allsecs % 3600) / 60)),
          seconds: addZero(that.data.allsecs % 60)
        }
      })
      that.data.allsecs--
        if (that.data.allsecs < 0) {
          clearInterval(that.data.timer);
          that.data.timer = null;
        }

      function addZero(n) {
        return n < 10 ? n = "0" + n : n;
      }
    }, 1000)
  },

  ljgmBtn:function(){
    wx.switchTab({
      url: '../shopping/shopping',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    var shopId;
    var that = this;
    wx.getStorage({
      key: 'shop',
      success: function(res) {
        that.data.shopId = res.data;
        var dts = wx.cloud.database();
        dts.collection('home_shujv').where({
          _id: that.data.shopId
        }).get({
          success: function(res) {
            wx.hideLoading();
            that.setData({
              list: res.data
            })
          }
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})